var util = require("../../../utils/util.js")
var app = getApp();
Page({
  data: {
    authdialog: getApp().globalData.source + "dialog/dialog.png",
    gzh: '天天必听',
    xiaobian: 'ttbtxb',
    showbanner:false,
    tbinfo: {},
    walletinfo:{},
    showit:false,
    authbg: getApp().globalData.authImg,
    authtitle: getApp().globalData.source + "red_packet/title1.png",
    authbtn2: getApp().globalData.source + "red_packet/btn2.png",
  },
  authbtn: function () {
    var vm = this
    wx.showLoading({
      title: "正在检查网络.."
    })
    this.setData({
      authbtn: true
    })
  },
  get: function() {
    wx.navigateTo({
      url: "../mydetail/mydetail",
      success: function () {      
      },
      fail: function () {
      }
    })
  },

  bindGetUserInfo: function (e) {
    app.authInfo(e);
  },
  // 一键复制事件 
  copyGzh: function(e) {
    var that = this;
    wx.setClipboardData({ //准备复制的数据     
      data: that.data.gzh,
      success: function(res) {
        wx.showToast({
          title: '复制成功',
        });
      }
    });
  },
  copyXiaoBian: function(e) {
    var that = this;
    wx.setClipboardData({ //准备复制的数据     
      data: that.data.xiaobian,
      success: function(res) {
        wx.showToast({
          title: '复制成功',
        });
      }
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    console.log(wx.getStorageSync("userId"))
    var pages = util.getCurrentPageUrl();
    console.log(pages)
    app.globalData.backType = pages
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    if (wx.getStorageSync("userId") == "" || wx.getStorageSync("userId") == undefined) {
      if (wx.getStorageSync("tourist")=="1"){
        if (wx.getStorageSync("authtype") == "0") {
          this.setData({
            showAuth: true,
            showAuth2: false
          })
        } else {
          this.setData({
            showAuth: false,
            showAuth2: true
          })
        }
        return
      }
    } else {
      this.setData({
        showAuth: false,
        showAuth2: false
      })
    }
    this.walletstate();
    this.setData({
      userInfo: wx.getStorageSync('userInfo'),
      ttbtSession: wx.getStorageSync('ttbtSession')
    })
    var vm = this
    var data = {
      userId: wx.getStorageSync("userId")
    }
    app.request(app.globalData.https + "hd/find/listen/length",
      "post", data,
      function(res) {
        vm.setData({
          tbinfo: res,
          showbanner:true
        })
      }
    )
  },
  walletstate:function(){
    var vm = this
    var data = {}
    app.request(app.globalData.https + "userResource/disableWallet",
      "get", data,
      function (res) {
        var iphone = wx.getStorageSync("iPhone");
        if (iphone != "-1") {
          vm.setData({
            showit: false,
          })
        } else {
          vm.setData({
            walletinfo: res.data,
            showit: true
          })
         
        }
      }
    )
  },
  myShareBindtap: function(e) {
    var id = e.currentTarget.dataset.id;
    console.log(id)
    wx.navigateTo({
      url: "../../day_day_listen/sharelist/sharelist?right="+true,
      success: function() {
      },
      fail: function() {
      }
    })
  },
  myFeedbackBindtap: function(e) {
    var id = e.currentTarget.dataset.id;
    console.log(id)
    wx.navigateTo({
      url: "../../my/feedback/feedback",
      success: function() {        
      },
      fail: function() {
      }
    })
  },
  myWalletBindtap: function(e) {
    var id = e.currentTarget.dataset.id;
    console.log(id)
    wx.navigateTo({
      url: "../../my/my_wallet/my_wallet",
      success: function() {
      },
      fail: function() {
      }
    })
  },
})